package com.sunday.demo.lod.handler;

import com.sunday.demo.lod.entity.Html;
import com.sunday.demo.lod.request.HtmlRequest;

/**
  @program: design-patterns
  @author: Jh
  @create: 2021-09-01 10:20
*/
public class HtmlDownLoader {

    NetWorkTransporter netWorkTransporter;

    public HtmlDownLoader(NetWorkTransporter netWorkTransporter) {
        this.netWorkTransporter = netWorkTransporter;
    }

    public Html download(String url) {
        HtmlRequest htmlRequest = new HtmlRequest(url);
        byte[] bytes = netWorkTransporter.send(htmlRequest.getAddress(),htmlRequest.getContent().getBytes());
        return new Html(bytes);
    }
}
